<!DOCTYPE html>
<html lang="zh-CN">

<head>
  <meta charset="UTF-8">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
</head>

<body>
  <input type="text" value="Hello world!">
  <button>select</button>

  <script>
    const input = document.querySelector('input')
    document.querySelector('button').addEventListener('click', () => {
      // 选中所有内容
      input.select()
    })
  </script>
</body>

</html>